char * strip_nastyhtml(const char * in);
char * convert_human_date_format(const char *human_datef); /* "MM,YYYY,DD" -> "%m,%Y,%d" */
char * convert_human_time_format(const char *human_timef); /* "HH+mm+ss" -> "%H+%M+%S" */
-char * pretty_deg_format(double lat, double lon, char fmt, int html); /* decimal -> dd.dddd or dd mm.mmm or dd mm ss */
+char * pretty_deg_format(double lat, double lon, char fmt, char *sep, int html); /* decimal -> dd.dddd or dd mm.mmm or dd mm ss */
char * get_filename(const char *fname); /* extract the filename portion */
str = xstrdup(wpt->notes);
}
else if (opt_pos)
- str = pretty_deg_format(wpt->latitude, wpt->longitude, 's', 0);
+ str = pretty_deg_format(wpt->latitude, wpt->longitude, 's', " ", 0);
if (str) { /* this will be stored into street-address field */
res += 22 + strlen(str);
gbfprintf(file_out, "\n<a name=\"%s\"><hr></a>\n", wpt->shortname);
gbfprintf(file_out, "<table width=\"100%%\">\n");
gbfprintf(file_out, "<tr><td><p class=\"gpsbabelwaypoint\">%s - ",(global_opts.synthesize_shortnames) ? mkshort_from_wpt(mkshort_handle, wpt) : wpt->shortname);
- cout = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], 1);
+ cout = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], " ", 1);
gbfprintf(file_out, "%s (%d%c %6.0f %7.0f)", cout, utmz, utmzc, utme, utmn);
xfree (cout);
if (wpt->altitude != unknown_alt)
if ( coordstr ) {
lon = atof( coordstr );
}
- coordstr = pretty_deg_format(lat, lon, degformat[2], 1);
+ coordstr = pretty_deg_format(lat, lon, degformat[2], " ", 1);
gbfprintf( file_out,
"<span class=\"gpsbabellogcoords\">%s</span><br>\n",
coordstr );
tm = time(NULL);
strftime(tbuf, sizeof(tbuf), "%d-%b-%Y", localtime(&tm));
- tmpout1 = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], 0);
+ tmpout1 = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], " ", 0);
if (wpt->altitude != unknown_alt) {
xasprintf(&altout, " alt:%d", (int) ( (altunits[0]=='f')?METERS_TO_FEET(wpt->altitude):wpt->altitude) );
}
if ( coordstr ) {
lon = atof( coordstr );
}
- coordstr = pretty_deg_format(lat, lon, degformat[2], 0);
+ coordstr = pretty_deg_format(lat, lon, degformat[2], " ", 0);
gbfprintf( file_out, "%s\n", coordstr);
xfree(coordstr);
}
* Return a decimal degree pair as
* DD.DDDDD DD MM.MMM or DD MM SS.S
* fmt = ['d', 'm', 's']
+ * sep = string between lat and lon (separator)
* html = 1 for html output otherwise text
*/
char *
-pretty_deg_format(double lat, double lon, char fmt, int html)
+pretty_deg_format(double lat, double lon, char fmt, char *sep, int html)
{
double latmin, lonmin, latsec, lonsec;
int latint, lonint;
lonmin = 60.0 * (fabs(lon) - lonint);
latsec = 60.0 * (latmin - floor(latmin));
lonsec = 60.0 * (lonmin - floor(lonmin));
+ if (sep == NULL) sep = " "; /* default " " */
if (fmt == 'd') { /* ddd */
- xasprintf ( &result, "%c%6.5f%s %c%6.5f%s",
- latsig, fabs(lat), html?"°":"",
+ xasprintf ( &result, "%c%6.5f%s%s%c%6.5f%s",
+ latsig, fabs(lat), html?"°":"", sep,
lonsig, fabs(lon), html?"°":"" );
}
else if (fmt == 's') { /* dms */
- xasprintf ( &result, "%c%d%s%02d'%04.1f\" %c%d%s%02d'%04.1f\"",
- latsig, latint, html?"°":" ", (int)latmin, latsec,
+ xasprintf ( &result, "%c%d%s%02d'%04.1f\"%s%c%d%s%02d'%04.1f\"",
+ latsig, latint, html?"°":" ", (int)latmin, latsec, sep,
lonsig, lonint, html?"°":" ", (int)lonmin, lonsec);
}
else { /* default dmm */
- xasprintf ( &result, "%c%d%s%06.3f %c%d%s%06.3f",
- latsig, latint, html?"°":" ", latmin,
+ xasprintf ( &result, "%c%d%s%06.3f%s%c%d%s%06.3f",
+ latsig, latint, html?"°":" ", latmin, sep,
lonsig, lonint, html?"°":" ", lonmin);
}
return result;